﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using StudentHookups.WCF;

namespace StudentHookups.Account
{
    public partial class MyProfile : System.Web.UI.Page
    {
        WCF.WCFClient client = new WCFClient();

        //Lägger till labels för att hitta de som är "gömda" i LoggedInTemplate
        Label lblFullname = new Label();
        Label Accountname = new Label();
        Label Age = new Label();
        Label Gender = new Label();
        Image ProfileImage = new Image();
        
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.IsAuthenticated)
            {
                lblFullname = (Label)MyProfileLogin.FindControl("Fullname");
                Accountname = (Label)MyProfileLogin.FindControl("Accountname");
                Age = (Label)MyProfileLogin.FindControl("Age");
                Gender = (Label)MyProfileLogin.FindControl("Gender");

                Guid user = (Guid)Membership.GetUser().ProviderUserKey;
                UserComposite loggedinUser = client.GetUser(user);

                lblFullname.Text = "<b>Fullname: </b>" + " " +loggedinUser.Firstname + " " + loggedinUser.Lastname;
                Accountname.Text = "<b>Username: </b>" + " " + loggedinUser.Username;
                Age.Text = "<b>Age: </b>" + " " + loggedinUser.Age.ToString();
                Gender.Text = "<b>Gender: </b>" + " " + loggedinUser.Gender;

               

                ProfileImage = (Image)MyProfileLogin.FindControl("ProfileImage");
                ProfileImage.ImageUrl = loggedinUser.Image;
            }
            
            
        }
    }
}